import { createRouter, createWebHistory } from "vue-router";

const router = createRouter({
  routes: [
    {
      path: "/login",
      //路由到的地址(自定义)
      name: "login",
      //组件名称
      component: () => import("../views/login.vue"),
      //引入组件，HomeComponent.vue所在路径
      //HomeComponent.vue是需要路由的vue组件
    },
    {
      path: "/",
      redirect: "/home",
      component: () => import("../views/layout/Layout.vue"),
      children: [
        {
          path: "home",
          component: () => import("../views/layout/home.vue"),
        },
        {
          path: "category",
          component: () => import("../views/layout/category.vue"),
        },
        {
          path: "cart",
          component: () => import("../views/layout/cart.vue"),
        },
        {
          path: "user",
          component: () => import("../views/layout/user.vue"),
        },
      ],
    },
    {
      path: "/search",
      component: () => import("../views/search/search.vue"),
    },
    {
      path: "/searchList",
      component: () => import("../views/search/list.vue"),
    },
    {
      path: "/prodetail/:id",
      component: () => import("../views/prodetail.vue"),
    },
    {
      path: "/pay",
      component: () => import("../views/pay.vue"),
    },
    {
      path: "/myorder",
      component: () => import("../views/myorder.vue"),
    },
  ],
  history: createWebHistory(),
});
export default router;
